package com.golfbox.oa.web.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.socket.TextMessage;

import com.golfbox.oa.msg.Constant;

@Controller
public class LoginController {

    @Autowired
    WebSocketHandlerOrder handler;


    @RequestMapping("/login.html")
    public @ResponseBody String login(HttpSession session,Integer userId) {
        System.out.println("======111===用户登录LoginSocketController======,userId="+userId);
        session.setAttribute(Constant.SESSION_KEY, userId);
        System.out.println("====2222=====用户登录LoginSocketController====" + session.getAttribute(Constant.SESSION_KEY));
        return "success";
    }

    @RequestMapping("/message")
    public @ResponseBody String sendMessage() {
        boolean hasSend = handler.sendMessageToUser(4, new TextMessage("发送一条小xi"));
        System.out.println(hasSend);
        return "message";
    }

}